//these arent quite opcodes, they are interrupts
#define CHECK_NMI					\
	if(Interrupts & INT_NMI)	\
		{								\
		if(WaitInterrupt)			\
			WaitInterrupt = 0;	\
		else							\
			{							\
			CC |= 0x80;				\
			PushS16(PC);			\
			PushS16(U);				\
			PushS16(Y);				\
			PushS16(X);				\
			PushS(DP);				\
			PushS(B);				\
			PushS(A);				\
			PushS(CC);				\
			}							\
		CC |= F_IRQ | F_FIRQ;	\
		PC = ReadWord(0xFFFC);	\
		Interrupts &= ~INT_NMI;	\
		Cycle += 19;				\
		}

#define CHECK_IRQ					\
	if((Interrupts & INT_IRQ) && ((CC & F_IRQ) == 0))	\
		{								\
		if(WaitInterrupt)			\
			WaitInterrupt = 0;	\
		else							\
			{							\
			CC |= 0x80;				\
			PushS16(PC);			\
			PushS16(U);				\
			PushS16(Y);				\
			PushS16(X);				\
			PushS(DP);				\
			PushS(B);				\
			PushS(A);				\
			PushS(CC);				\
			}							\
		CC |= F_IRQ;				\
		PC = ReadWord(0xFFF8);	\
		Interrupts &= ~INT_IRQ;	\
		Cycle += 19;				\
		}

#define CHECK_FIRQ				\
	if((Interrupts & INT_FIRQ) && ((CC & F_FIRQ) == 0))	\
		{								\
		if(WaitInterrupt)			\
			WaitInterrupt = 0;	\
		else							\
			{							\
			CC &= ~0x80;			\
			PushS16(PC);			\
			PushS(CC);				\
			}							\
		CC |= F_IRQ | F_FIRQ;	\
		PC = ReadWord(0xFFF6);	\
		Interrupts &= ~INT_FIRQ;\
		Cycle += 10;				\
		}

#define CHECK_INTERRUPTS		\
	if(Interrupts)					\
		{								\
		CHECK_NMI;					\
		CHECK_FIRQ;					\
		CHECK_IRQ;					\
		}

#define DIRECT_IM				\
	tmp = Read(PC++);			\
	EA = (DP << 8) | Read(PC++);

#define OIM						\
	tmp |= Read(EA);			\
	CC &= ~(F_ZERO | F_NEGATIVE | F_OVERFLOW);	\
	CheckNZ(tmp);				\
	Write(EA,tmp);

#define AIM						\
	tmp &= Read(EA);			\
	CC &= ~(F_ZERO | F_NEGATIVE | F_OVERFLOW);	\
	CheckNZ(tmp);				\
	Write(EA,tmp);

#define EIM						\
	tmp ^= Read(EA);			\
	CC &= ~(F_ZERO | F_NEGATIVE | F_OVERFLOW);	\
	CheckNZ(tmp);				\
	Write(EA,tmp);

#define TIM						\
	tmp &= Read(EA);			\
	CC &= ~(F_ZERO | F_NEGATIVE | F_OVERFLOW);	\
	CheckNZ(tmp);

#define LDMD					\
	MD = Read(EA);				\
	ModeChange();